/*! ============================================================================
 * @file timer.cpp 
 * @Synopsis  
 * @author DongKai
 * @version 1.0
 * @date 2009年12月04日
 *  Company: Beijing Feynman Software Technology Co., Ltd.
 */

#include <timer.hpp>

namespace utilx
{
    const unsigned long MICROSECOND = 1000000L;

    Timer::Timer()
    {
        memset(start_, 0, sizeof(start_));
        memset(end_, 0, sizeof(end_));
    }		/* -----  end of method Timer::Timer  ----- */

    ~Timer::Timer()
    {

    }

    inline void 
        Timer::start_timing()
    {
        gettimeofday(&start_, NULL);
    }

    inline void
        Timer::stop_timing()
    {
        gettimeofday(&end_, NULL);
    }

    inline unsigned long 
        Timer::get_interval()
    {
        return (MICROSECOND * ( end_.tv_sec - start_.tv_sec ) + 
                end_.tv_usec - start_.tv_usec); 
    }

}
